<template>
  <section class="sp-control">
    <el-button type="primary" v-if="button" @click="create">{{ buttonText }}</el-button>
    <el-pagination @current-change="change" background layout="total, prev, pager, next" :total="total" />
  </section>
</template>

<script>
export default {
  name: 'SpControl',
  components: {},
  props: {
    button: {
      type: Boolean,
      default: true
    },
    buttonText: {
      type: String,
      default: '新增'
    },
    total: {
      type: Number,
      default: 0
    }
  },
  data () {
    return {}
  },
  created () {},
  mounted () {},
  destroyed () {},
  methods: {
    // 新增
    create () {
      this.$emit('create')
    },
    // 切换页码
    change (e) {
      this.$emit('change', e)
    }
  }
}
</script>

<style lang="scss" scoped>
  .sp-control {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
</style>
